/**
 * Created by hdw on 2017/8/14.
 */
import React, {Component} from 'react'
import {Link} from 'react-router'
import '../sass/AddressSelect.scss'

export default class AddressSelect extends Component {
  constructor() {
    super()
  }

  render() {
    let {cancelSelect, confirmOrderAddressVos, changeAddress} = this.props

    return (
        <div className="address-select">
            <div className="address-select-box">
                <div className="address-select-top">
                    <Link className="link fl cancel" onClick={cancelSelect.bind(this)}>取消</Link>
                    <Link className="link fr" to="/editaddress/0">新增地址</Link>
                </div>
                <div className="address-select-list">
                    {
                        confirmOrderAddressVos.map((item, index) =>
                            <div className="address" key={index} onClick={changeAddress.bind(this, {type: item.type, areaId: item.expressId})}>
                                <div className="sign">
                                    {item.type == 1 ? <span className="pick">自提</span> : <span className="delivery">配送</span>}
                                </div>
                                <div className={item.selected ? 'detail active' : 'detail'}>
                                    <p>{item.type == 1 ? item.siteName : item.address}</p>
                                    <span>{item.type == 1 ? item.address : `${item.userName} ${item.telephone}`}</span>
                                </div>
                            </div>
                        )
                    }
                </div>
            </div>
        </div>
    )
  }
}
